package cn.hesion.leetcode;
/**
 * ClassName: CompareVersion <br/>
 * Description: <br/>
 * date: 2022/5/16 21:23<br/>
 *
 * @author Hesion<br />
 * @version
 * @since JDK 1.8
 */

/**
 *
 * @author: hesion
 * @create: 2022-05-16 21:23
 **/
public class CompareVersion {
    public int compareVersion(String version1, String version2) {
        int n = version1.length(),m=version2.length();
        int i=0,j=0;
        while (i<n||j<m){
            int x=0;
            for(;i<n&&version1.charAt(i)!='.';++i){
                x=x*10+version1.charAt(i)-'0';
            }
            ++i;
            int y=0;
            for(;j<m&&version2.charAt(j)!='.';++j){
                y=y*10+version2.charAt(j)-'0';
            }
            ++j;
            if(x!=y){
                return x>y?1:-1;
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        System.out.println(new CompareVersion().compareVersion("1.01", "1.001"));
    }
}
